{extend name="base" /}
<!-- page specific plugin styles -->
{block name="inline-styles"}
{/block}
<!-- PAGE CONTENT BEGINS -->
{block name="content"}
<div class="page js_show">
    <div class="page__bd">
        <div class="weui-wepay-lists">
            <div class="weui-wepay-lists__hd">
                <div class="weui-wepay-lists__menu">
                    <a class="weui-wepay-lists__menu__item" href="{:url('Index/recharge_list')}">充值申请</a>
                    <a class="weui-wepay-lists__menu__item weui-wepay-lists__menu__item_on" href="{:url('Index/withdraw_list')}">提现申请</a>
                </div>
            </div>
            <div class="weui-wepay-lists__bd">
                <div class="weui-cells" style="margin-top:0" id="listData">
                    <!-- <a class="weui-cell weui-cell_primary" href="javascript:;">
                        <div class="weui-cell__hd">
                            <img src="/static/weui-extension/dist/example/images/list_eg_img_1.jpg" alt="" width="34" height="34">
                        </div>
                        <div class="weui-cell__bd">
                            <div class="weui-cell__title">聚会AA</div>
                            <div class="weui-cell__info">2016-07-11 21:49:29</div>
                        </div>
                        <div class="weui-cell__ft">
                            <div class="weui-cell__title weui-wepay-color-orange">+1000.00</div>
                            <div class="weui-cell__info">已审核</div>
                        </div>
                    </a> -->
                </div>
                <div class="weui-loadmore" style="display: none"> 
                    <i class="weui-loading"></i>
                    <span class="weui-loadmore__tips">正在加载</span>
                </div>
            </div>
        </div>
    
    </div>
</div>
{/block}
<!-- PAGE CONTENT ENDS -->
<!-- inline scripts related to this page -->
{block name="related-scripts"}
<script type="text/javascript">
    $.ajax({
        url: '/api/v1/member/withdraw_list',
        type: 'POST',
        dataType: 'json',
        data:{
            draw: 1
        }
    })
    .done(function(json) {
        console.log("success");
        renderData("#listData",json.data);
    })
    .fail(function() {
        console.log("error");
    })
    .always(function() {
        console.log("complete");
    });
    // 渲染列表
    function renderData(_elment,_data){
        for(var i= 0; i<_data.length;i++){
            var _item =
            '<a class="weui-cell weui-cell_primary" href="{:url('Index/withdraw_detail')}?id='+_data[i].id+'">\
                <div class="weui-cell__hd">\
                    <img src="'+_data[i].avatar+'" alt="" width="34" height="34">\
                </div>\
                <div class="weui-cell__bd">\
                    <div class="weui-cell__title">'+_data[i].nickname+'</div>\
                    <div class="weui-cell__info">'+_data[i].ctime+'</div>\
                </div>\
                <div class="weui-cell__ft">\
                    <div class="weui-cell__title weui-wepay-color-orange">-'+_data[i].money+'</div>\
                    <div class="weui-cell__info">'+_data[i].status_name+'</div>\
                </div>\
            </a>';

            $(_elment).append(_item);
        }
    }

    var loading = false;  //状态标记
    var _draw = 2;
    $(".weui-wepay-lists").infinite().on("infinite", function() {
        if(loading) return;
        loading = true;
        $.ajax({
            url: '/api/v1/member/withdraw_list',
            type: 'POST',
            dataType: 'json',
            data:{
                draw: _draw
            }
        })
        .done(function(json) {
            console.log("success");
            if(json.data.length>0){
                loading = false;
                _draw++;
                renderData("#listData",json.data);
            }
        })
        .fail(function() {
            console.log("error");
        })
        .always(function() {
            console.log("complete");
        });
    });

//重置浏览器回退链接
browserBack("assets.html");

</script>
{/block}